package w5

object Shouhou {

  def main(args: Array[String]): Unit = {
    val c = new Camera("先锋", 6999)
    repair(c)
    val c2 = new DigitalCamera("佳能s9000", 19999)
    repair(c2)
  }

  def repair(c: Camera): Unit = {
    println("维修开始，测试一下是否可用")
    c.takePhoto("墙壁")
    //c.connect()
    //c.ontimeTake(11)
    if (c.isInstanceOf[DigitalCamera]) {
      val dc = c.asInstanceOf[DigitalCamera] //向下转型
      dc.connect()
      dc.ontimeTake(11)
    } else {
      println("这不是数码相机")
    }
  }
}
